<%@ page language="java" contentType="text/html; charset=UTF-8"%>
<%@include file="/pageRc/common/common.jsp"%>

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="viewport"
	content="initial-scale=1.0,maximum-scale=1.0,user-scalable=no">
<meta name="format-detection" content="telephone=no">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="mobile-web-app-capable" content="yes">
<meta name="msapplication-tap-highlight" content="no">
<link rel="stylesheet" href="<%=commonPath%>/pageRc/css/time/index.css?rev=ac6ed5b7b7b35822066a7c1ff4367280">
<link rel="stylesheet" href="<%=commonPath%>/pageRc/css/time/iosSelect.css">
<link rel="stylesheet" href="<%=commonPath%>/pageRc/layui/css/layui.css"media="all">
<link rel="stylesheet" href="<%=commonPath %>/res/css/global.css"> 
<script type="text/javascript"
	src="<%=commonPath%>/pageRc/js/jquery-1.9.1.min.js"></script>
<script type="text/javascript"
	src="<%=commonPath%>/pageRc/common/utils.js"></script>
<script type="text/javascript"
	src="<%=commonPath%>/pageRc/common/msgTool.js"></script>
<script type="text/javascript"
	src="<%=commonPath%>/pageRc/layui/layui.js"></script>
<%-- <script type="text/javascript" src="<%=commonPath%>/pageRc/js/time/jquery.min.js"></script> --%>
<script type="text/javascript" src="<%=commonPath%>/pageRc/js/time/flexible.debug.js"></script>
<%-- <script type="text/javascript" src="<%=commonPath%>/pageRc/js/time/flexible_css.debug.js"></script> --%>
<script type="text/javascript" src="<%=commonPath%>/pageRc/js/time/mobileFix.js"></script>
<script type="text/javascript" src="<%=commonPath%>/pageRc/js/time/swiper.min.js"></script>
<script type="text/javascript" src="<%=commonPath%>/pageRc/js/time/kinerDatePicker.js"></script>
<script type="text/javascript" src="<%=commonPath%>/pageRc/js/time/iscroll.js"></script>
<script type="text/javascript" src="<%=commonPath%>/pageRc/js/time/iosSelect.js"></script>

<title>报工审核</title>
<script type="text/javascript">
var ua = navigator.userAgent.toLowerCase();
	if(ua.match(/MicroMessenger/i)=="micromessenger") {//微信
	  if('${wechatUrl}'!="0"){
		  window.location.href = "${wechatUrl}";
	  }
	}
</script>
<style type="text/css">

.list-lib{
	width: 96%;
	height:120px;
    margin-left: 2%;
    margin-bottom:10px;
    margin-top:10px;
    background-color: #fff!important;
    /* position:relative; */
}
.list-lib-al{
    border-radius: 2px;
} 

.list-left{
	width:100%;
	float:left;	
}
.list-left div{
	font-size:12px;
	line-height:20px;
}
.list-left span{
	font-size:12px;
	line-height:20px!important;
}
.list-right{
	/* position:absolute; */

}
.ture-btn{
	width:30px;
	float:left;
     display: inline-block;
    height: 30px;
    line-height: 30px;
    background-color: #009688;
    color: #fff;
    white-space: nowrap;
    text-align: center;
    font-size: 14px;
    border: none;
    border-radius: 2px;
    cursor: pointer;
    opacity: .9;
 
}

.no-btn{
	width:30px;
	float:right;
     display: inline-block;
    height: 30px;
    line-height: 30px;
    background-color: #009688;
    color: #fff;
    white-space: nowrap;
    text-align: center;
    font-size: 14px;
    border: none;
    border-radius: 2px;
    cursor: pointer;
    opacity: .9;
 
}
</style>

</head>
<body>
<div class="header">
  <blockquote class="layui-elem-quote">报工审核</blockquote>
 </div>
 <form id="createMsgForm" name="createMsgForm" class="layui-form">
			<input type="hidden" class="layui-input" value="${proTeamNo}" id="proTeamNo" />
			<input type="hidden" class="layui-input" value="${proGroupNo}" id="proGroupNo" />
			<input type="hidden" class="layui-input" value="${positionType}" id="positionType" />
			<input type="hidden" class="layui-input" value="${rouid}" id="rouid" />
			<div class="layui-form-item">
				<div class="layui-inline">
					<div class="layui-inline">
						<select name="needId" id="needId" lay-filter="needId">
							<option value="">需求编号----需求名称</option>
							<option value="">全部</option>
							<c:forEach items="${needInforList}" var="needInfor">
								<c:if test="${needInfor.rouid == needId}">
									<option value="${needInfor.rouid}" selected='selected'><c:if test="${fn:length(needInfor.needNo) > 10 }">${fn:substring(needInfor.needNo,0,10)}...</c:if><c:if test="${fn:length(needInfor.needNo) <= 10 }">${needInfor.needNo}</c:if>----<c:if test="${fn:length(needInfor.needName) > 10 }">${fn:substring(needInfor.needName,0,10)}...</c:if><c:if test="${fn:length(needInfor.needName) <= 10 }">${needInfor.needName}</c:if></option>
								</c:if>
								<c:if test="${needInfor.rouid != needId}">
									<option value="${needInfor.rouid}"><c:if test="${fn:length(needInfor.needNo) > 10 }">${fn:substring(needInfor.needNo,0,10)}...</c:if><c:if test="${fn:length(needInfor.needNo) <= 10 }">${needInfor.needNo}</c:if>----<c:if test="${fn:length(needInfor.needName) > 10 }">${fn:substring(needInfor.needName,0,10)}...</c:if><c:if test="${fn:length(needInfor.needName) <= 10 }">${needInfor.needName}</c:if></option>
								</c:if>
							</c:forEach>
						</select>
						<%-- <input class="layui-input" type="hidden" name="needId" id="needId" value="${needId}" />	
						<input class="layui-input" type="" name="showNeedList" id="showNeedList" value="${choseName}" placeholder="需求编号----需求名称" />	 --%>
					</div>
					<div class="layui-inline">
						<input class="layui-input kinerDatePickerInput" style="width: 60%;display: inline;float: left;" id="happenDate" title="报工日期"  startYear="1991" default-val="2018-10-1" placeholder="报工日期" value="${happenDate}" />
						<button class="layui-btn" style="width: 19%;float: left; display: inline;margin-left: 2px;margin-right: 0px;" type="button" id="doClear" onClick="doClearTime()" >清空</button>
						<button class="layui-btn" style="width: 19%;float: right; display: inline;margin-left: 0px;margin-right: 3px;" type="button" id="doSearchSum" onClick="search()" >查询</button>
					</div>
				</div>
			</div>
		</form>
		<div class="layui-inline">
			<button class="layui-btn" style=" margin-left: 10px; display: none;" type="button" id="allCheck" lay-filter="allChoose" >全选</button>
			<button class="layui-btn" style=" margin-left: 10px; display: none;" type="button" id="noCheck" lay-filter="noChoose" >全不选</button>
			<button class="layui-btn" style=" display: inline;" type="button" id="editButton" onClick="editJob()" >批量审核</button>
			<button class="layui-btn layui-btn-small" style="float: right; margin-right: 20px; display: none; width: 40px;height: 40px;" id="unPassButton" onClick="passAll('','02')" ><i class="layui-icon" style="">&#x1006;</i></button>
			<button class="layui-btn layui-btn-small" style="float: right; display: none; width: 40px;height: 40px;" id="passButton" onClick="passAll('','01');" ><i class="layui-icon" style="">&#xe605;</i></button>
			<button class="layui-btn" style="float: right; display: none;" type="button" id="cancleButton" onClick="cancle()" >取消</button>
		</div>
 <div style="layui-main" class="layui-form"> 
	 <c:forEach items="${list}" var="job" > 
		 <div class="list-lib">
			 <div class="list-lib-al">
			  	<div class="list-left">
				 	<div style="padding:5px;">
				 		<div style="line-height: 30px;">
						 		<c:if test="${job.reportState == '00'}">
					            	<span style="color: red;font-size: 15px;">未审核</span>
					            </c:if>
					            <c:if test="${job.reportState == '01'}">
					            	<span style="font-size: 15px;">审核通过</span>
					            </c:if>
					            <c:if test="${job.reportState == '02'}">
					            	<span style="color: red;font-size: 15px;">审核未通过</span>
					            </c:if>
					            <c:if test="${job.sign == '0'}">
					            	<span style="color: red;font-size: 15px;">(报工重复)</span>
					            </c:if>
						 	<div style="float:right;width:70px;">
							 	<button class="ture-btn" id="" name="confirmButton" onClick="confirmJob('${job.rouid}', '01')"><i class="layui-icon" style="">&#xe605;</i></button>
							 	<button class="no-btn" id="" name="confirmButton" onClick="confirmJob('${job.rouid}', '02')"><i class="layui-icon" style="">&#x1006;</i></button>
							 	<div name="checkBox" class="no-btn layui-hide">
							      <input type="checkbox" name="like" value="${job.rouid}" />
							    </div>
						 	</div>
					 	</div>
					 	<div>
						 	<span><i class="layui-icon" style="font-size: 12px; color: #009688;">&#xe617;</i> ${job.userName}/${job.happenDate}</span>
						 	<span style="padding-left:15px;">${job.needUseTime}小时/${job.stage}</span>
					 	</div>
					 	<div>
						 	<div><i class="layui-icon" style="font-size: 12px; color: #5FB878;">&#xe617;</i> 需求编号：<span style="color: #999;">${job.needNo}</span></div>
						 	<div><i class="layui-icon" style="font-size: 12px; color: #FF5722;">&#xe617;</i> 需求名称：<span style="color: #999;">${job.needName}</span></div>
					 	</div>
					 	<div>
					 	<i class="layui-icon" style="font-size: 12px; color: #F7B824;">&#xe617;</i> 详情：<span style="color: #999;">${job.remark}</span>
					 	</div>
				 	</div>
			 	</div>		
			 </div>
		 </div>
	 </c:forEach>
</div>
</body>
<script type="text/javascript">
var path="<%=commonPath%>";
	var msg = new msgTool();
	layui.use([ 'form', 'layer', 'laytpl', 'laypage', 'laydate' ],
			function(){
			var $ = layui.jquery, layer = layui.layer; //独立版的layer无需执行这一句
			var form = layui.form(), layer = layui.layer, laypage = layui.laypage, laytpl = layui.laytpl;
			$(document).on('click','#allCheck',function(){
				$("#noCheck").css("display", "inline");
				$("#allCheck").css("display", "none");
				$("input[name='like']").each(function () {
		            this.checked = true;
		        });
		        form.render('checkbox');
			});
			$(document).on('click','#noCheck',function(){
				$("#allCheck").css("display", "inline");
				$("#noCheck").css("display", "none");
				$("input[name='like']").each(function () {
		            this.checked = false;
		        });
		        form.render('checkbox');
			});
	});

function search(){
	var happenDate = $("#happenDate").val();
	var	proTeamNo = $("#proTeamNo").val();
	var	proGroupNo = $("#proGroupNo").val();
	var	positionType = $("#positionType").val();
	var	rouid = $("#rouid").val();
	var needId = $("#needId").val();
	//var choseName = $("#showNeedList").val();
	var pars = "proGroupNo="+proGroupNo+"&proTeamNo="+proTeamNo+"&rouid="+rouid+"&happenDate="+happenDate+"&needId="+needId+"&positionType="+positionType;
	//var pars = "proGroupNo="+proGroupNo+"&proTeamNo="+proTeamNo+"&rouid="+rouid+"&happenDate="+happenDate+"&needId="+needId+"&positionType="+positionType+"&choseName="+choseName;
	var href = "<%=commonPath %>/page/job/searchReviewJob.do?"+pars;
	location.href =href;
}

function doClearTime(){
	$("#happenDate").val("");
}

function confirmJob(rouid, sign) {
 var jsonDate = {};
       jsonDate.rouid = rouid;
       jsonDate.reportState = sign;
       var index = parent.layer.getFrameIndex(window.name); //获取当前窗体索引
       var message = "";
       if(sign == '01'){
       	message = "确认审核通过?";
       }else if(sign == '02'){
       	message = "确认审核不通过?";
       }
       layer.confirm(message, {icon:3,title:"提示"},function(index){
			msg.sendMsg("/page/job/confirmJob.do",jsonDate,function(data){
				var rsObj = null;
				var	proTeamNo = $("#proTeamNo").val();
				var	proGroupNo = $("#proGroupNo").val();
				var	positionType = $("#positionType").val();
				var	rouid = $("#rouid").val();
				var happenDate = $("#happenDate").val();
				var needId = $("#needId").val();
				//var choseName = $("#showNeedList").val();
				var pars = "proGroupNo="+proGroupNo+"&proTeamNo="+proTeamNo+"&rouid="+rouid+"&happenDate="+happenDate+"&needId="+needId+"&positionType="+positionType;
				//var pars = "proGroupNo="+proGroupNo+"&proTeamNo="+proTeamNo+"&rouid="+rouid+"&happenDate="+happenDate+"&needId="+needId+"&positionType="+positionType+"&choseName="+choseName;
				var href = "<%=commonPath %>/page/job/searchReviewJob.do?"+pars;
	            if (msg.isJson(data)) {
	                rsObj = data
	            } else {
	                rsObj = JSON.parse(data);
	            }
	           
	            var retCode = rsObj.head.retCode;
	            if (retCode !== '0000') {
	                layer.alert("操作失败！");
	            } else {
	            	 layer.alert("操作成功！");
	                location.href =href;
	           }
			});
	   }); 
}
	 function editJob(){
		 $("#editButton").css("display", "none");
		 $("#passButton").css("display", "inline");
		 $("#unPassButton").css("display", "inline");
		 $("#cancleButton").css("display", "inline");
		 $("#allCheck").css("display", "inline");
		 $("#noCheck").css("display", "none");
		 $("div[name='checkBox']").removeClass("layui-hide").addClass("layui-show");
		 $("button[name='confirmButton']").css("display", "none");
		 $("div[name='confirmButton']").removeClass("layui-show").addClass("layui-hide");
	 }
	 
	 function cancle(){
		 $("#editButton").css("display", "inline");
		 $("#passButton").css("display", "none");
		 $("#unPassButton").css("display", "none");
		 $("#cancleButton").css("display", "none");
		 $("#allCheck").css("display", "none");
		 $("#noCheck").css("display", "none");
		 $("div[name='checkBox']").removeClass("layui-show").addClass("layui-hide");
		 $("button[name='confirmButton']").css("display", "inline");
		 $("div[name='confirmButton']").removeClass("layui-hide").addClass("layui-show");
	 }
	 
	 function passAll(rouid, sign){
		 var arr = new Array();
         $("input:checkbox[name='like']:checked").each(function(i){
			arr[i] = $(this).val();
         });
		var checkedRouId = arr.join(",");
		if(arr.length == 0){
			layer.alert("请选择要审核的报工记录！");
		}else{
			var jsonDate = {};
	       jsonDate.rouid = checkedRouId;
	       jsonDate.reportState = sign;
	       var index = parent.layer.getFrameIndex(window.name); //获取当前窗体索引
	       var message = "";
	       if(sign == '01'){
	       	message = "确认审核通过?";
	       }else if(sign == '02'){
	       	message = "确认审核不通过?";
	       }
	       layer.confirm(message, {icon:3,title:"提示"},function(index){
				msg.sendMsg("/page/job/passAll.do",jsonDate,function(data){
					var rsObj = null;
					var	proTeamNo = $("#proTeamNo").val();
					var	proGroupNo = $("#proGroupNo").val();
					var	positionType = $("#positionType").val();
					var	rouid = $("#rouid").val();
					var happenDate = $("#happenDate").val();
					var needId = $("#needId").val();
					//var choseName = $("#showNeedList").val();
					var pars = "proGroupNo="+proGroupNo+"&proTeamNo="+proTeamNo+"&rouid="+rouid+"&happenDate="+happenDate+"&needId="+needId+"&positionType="+positionType;
					//var pars = "proGroupNo="+proGroupNo+"&proTeamNo="+proTeamNo+"&rouid="+rouid+"&happenDate="+happenDate+"&needId="+needId+"&positionType="+positionType+"&choseName="+choseName;
					var href = "<%=commonPath %>/page/job/searchReviewJob.do?"+pars;
		            if (msg.isJson(data)) {
		                rsObj = data
		            } else {
		                rsObj = JSON.parse(data);
		            }
		            var retCode = rsObj.head.retCode;
		            if (retCode !== '0000') {
		                layer.alert("操作失败！");
		            } else {
		            	 layer.alert("操作成功！");
		                location.href =href;
		           }
				});
		   }); 
		}
	 }
	 
	 $(document).ready(function () {
	 	if('${happenDate}' == null || '${happenDate}' == ''){
	 		var d=new Date();
	        $('#happenDate').attr('default-val', d.getFullYear()+"-"+(d.getMonth()+1)+"-"+d.getDate());
	 	}else{
	 		$('#happenDate').attr('default-val','${happenDate}'.substring(0,4)+"-"+'${happenDate}'.substring(4,6)+"-"+'${happenDate}'.substring(6,8));
	 	}
        $('#happenDate').kinerDatePicker({
            clickMaskHide: true,
            showHandler: function (ctx) {
            },
            hideHandler: function (ctx) {
            },
            changeHandler: function (vals, ctx) {
            },
            okHandler: function (vals, ctx) {
            	var happenDate = vals[0]+""+vals[1]+""+vals[2];
            	$('#happenDate').val(happenDate);
            },
            cancelHandler: function (ctx) {
            }
        });
    })
    
    /* var needIdDom = document.querySelector('#needId');
    var showNeedListDom = document.querySelector('#showNeedList');
    showNeedListDom.addEventListener('click', function () {
        var needId = showNeedListDom.dataset['id'];
        var needName = showNeedListDom.dataset['value'];
		var data = ${needInforList};
        var bankSelect = new IosSelect(1, [data],
            {
                container: '.container',
                title: '需求编号-名称',
                itemHeight: 50,
                itemShowCount: 3,
                oneLevelId: needId,
                callback: function (selectOneObj) {
                	needIdDom.value = selectOneObj.rouid;
                	showNeedListDom.value = selectOneObj.needno+'-'+selectOneObj.needname;
                }
        });
    }); */
</script>

</html>